@extends('dashboard.base')

@section('content')
<div class="container-fluid">
	<div class="row">
		<div class="col">
			<div class="card">
          <div class="card-header"><strong>添加</div>
            <div class="card-body">
              <form class="form-horizontal" action="{{ empty($data)? route('admin.goods.store'):route('admin.goods.update', $data) }}" method="post">
                @text([
                'name' => 'name', 
                'label' => '商品名称', 
                'default' => $data->name??''
                ]) 
                @endtext

                @category_select(['label' => '商品分类', 'default' => $data->category_id??'', 'default_text' => '请选择', 'name' => 'category_id'])
                
                @brand_select(['default' => $data->brand_id??''])

                @text(['name' => 'sub_title', 'label' => '简短描述', 'default' => $data->sub_title??'']) @endtext
                
                @upload(['label' => '封面图', 'name'=> 'cover_img', 'default' => $data->cover_img??'', 'element' => 'picture'])
                @endupload
                
                @text(['name' => 'market_price', 'type' => 'number', 'label' => '市场价', 'default' => $data->market_price??'']) @endtext

                @text(['name' => 'price', 'type' => 'number', 'label' => '本店售价', 'default' => $data->price??'']) @endtext

                @text(['name' => 'stock', 'label' => '库存', 'default' => $data->stock??'', 'type' => 'number']) @endtext

                @include('dashboard.includes.goods.goods_type', ['data' => $data??''])
                @include('dashboard.includes.goods.goods_status')

                @text(['label' => '虚拟销量', 'name' => 'virtual_sales', 'type' => 'number', 'default' => $data->virtual_sales??0]) @endtext

                @attr(['name' => 'attr', 'data' => $data->attrs??[]]) @endattr
                
                @upload(['name' => 'picture', 'label' => '展示图', 'multiple' => 1, 'element' => 'album', 'default' => $data->pictures??[]]) @endupload
                @editor(['label' => '商品描述', 'default' => $data->description??'']) @endeditor

                @csrf
                @isset($data)
			            @method('PUT')
                @endisset

                <div class="form-group row">
                  <label class="col-md-2 col-form-label" for="text-input"></label>
                  <div class="col-md-9">
                    <button type="submit" class="btn btn-sm btn-primary">提交</button>
                  </div>
                </div>
              </form>
            </div>
            @errmsg
            @enderrmsg
      </div>
		</div>
	</div>
</div>	
@endsection

@section('javascript')
<script>
</script>
@endsection